package cn.com.huaxun.controller;

import cn.com.huaxun.module.user.entity.StudentEntity;
import cn.com.huaxun.module.user.service.StudentService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.dubbo.config.annotation.Reference;

/**
 * 
 * @ClassName: DemoConsumerController
 * @Description:web调用服务提供者对外暴露的rpc接口
 * @author: niugang
 * @date: 2018年8月18日 上午9:41:30
 * @Copyright: 863263957@qq.com. All rights reserved.
 *
 */
@RestController
public class DemoConsumerController {

    /**
     * 引入dubbo提供者
     */
	@Reference(timeout = 10000,retries = 2,cluster = "failfast")
	private StudentService studentService;

	/**
	 * @description 调用提供者
	 * @method  sayHello
	 * @param  [id]
	 * @return java.lang.String
	 * @date: 2019/1/2 9:54
	 * @author:zhoujinbing
	 */
	@RequestMapping("/sayHello")
	public String sayHello(@RequestParam long id) {
		return studentService.selectById(id).toString();
	}

	@RequestMapping("/sendStudent")
	public void sendStudent()
	{
		StudentEntity studentEntity = new StudentEntity();
		studentEntity.setId(1);
		studentEntity.setName("哈哈");
		studentService.sendKafkaMessage("jack",studentEntity);
	}

}